
/**
 * PayPalConfig.java
 * @author Jason Lu
 * @date 2013-9-24
 * @version 1.0
 */
package com.x52im.mall;

import java.math.BigDecimal;

import android.content.Context;
import android.content.Intent;

import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;

/**
 * @author Jason
 * 
 */
public class PayPalConfig
{
	
	// set to PaymentActivity.ENVIRONMENT_LIVE to move real money.
	// set to PaymentActivity.ENVIRONMENT_SANDBOX to use your test credentials from https://developer.paypal.com
	// set to PaymentActivity.ENVIRONMENT_NO_NETWORK to kick the tires without communicating to PayPal's servers.
	public static final String CONFIG_ENVIRONMENT = PaymentActivity.ENVIRONMENT_LIVE;
	// note that these credentials will differ between live & sandbox environments.
	
	public static final String CONFIG_CLIENT_ID = "AaUGDxDlReZWHdJJ5mC_JBuXHzrrRqxHTQ4bEEvo4XHKZ-GKGa0hUK8NMl26";
	// when testing in sandbox, this is likely the -facilitator email address.
	public static final String CONFIG_RECEIVER_EMAIL = "support@efeelink.com";
	
	public static Intent getPayPalServiceIntent(Context context)
	{
		Intent intent = new Intent(context, PayPalService.class);
		intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
		intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
		intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
		
		return intent;
	}
	
	public static Intent getPayPayActivityIntent(Context context,String amount, String currency, String shortDesc)
	{
		PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(amount), currency, shortDesc);

		Intent intent = new Intent(context, PaymentActivity.class);

		intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
		intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
		intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

		// It's important to repeat the clientId here so that the SDK has it if
		// Android restarts your app midway through the payment UI flow.
		intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
		intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "");
		intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

		return intent;
	}
}
